package com.hkts.naturalgas.performance.service.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.hkts.naturalgas.performance.entity.HkFormIndex;
import com.hkts.naturalgas.performance.mapper.HkFormIndexMapper;
import com.hkts.naturalgas.performance.service.IHkFormIndexService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yck
 * @since 2020-12-22
 */
@Service
@Transactional
public class HkFormIndexServiceImpl extends ServiceImpl<HkFormIndexMapper, HkFormIndex> implements IHkFormIndexService {


@Autowired
private HkFormIndexMapper hkFormIndexMapper;

@Override
public IPage<HkFormIndex> selectPage(Page<HkFormIndex> page, HkFormIndex hkFormIndex){
        QueryWrapper<HkFormIndex> query = Wrappers.query();
        QueryWrapper<HkFormIndex> entityWrapper = getEntityWrapper(query, hkFormIndex);
        return hkFormIndexMapper.selectPage(page, entityWrapper);
        }




@Override
public List<HkFormIndex> selectList(HkFormIndex hkFormIndex){
        QueryWrapper<HkFormIndex> query = Wrappers.query();
        QueryWrapper<HkFormIndex> entityWrapper = getEntityWrapper(query, hkFormIndex);
        return hkFormIndexMapper.selectList(entityWrapper);
        }

/**
 *  公共查询条件
 * @param entityWrapper
 * @return
 */
public QueryWrapper<HkFormIndex> getEntityWrapper(QueryWrapper<HkFormIndex> entityWrapper,HkFormIndex hkFormIndex){
        //条件拼接
                if(StringUtils.isNotBlank(hkFormIndex.getCreateBy())){
                entityWrapper.like(HkFormIndex.CREATE_BY,hkFormIndex.getCreateBy());
                }
              /*  if(StringUtils.isNotBlank(hkFormIndex.getCreateTime())){
                entityWrapper.like(HkFormIndex.CREATE_TIME,hkFormIndex.getCreateTime());
                }
                if(StringUtils.isNotBlank(hkFormIndex.getDelFlag())){
                entityWrapper.like(HkFormIndex.DEL_FLAG,hkFormIndex.getDelFlag());
                }
                if(StringUtils.isNotBlank(hkFormIndex.getUpdateBy())){
                entityWrapper.like(HkFormIndex.UPDATE_BY,hkFormIndex.getUpdateBy());
                }
                if(StringUtils.isNotBlank(hkFormIndex.getUpdateTime())){
                entityWrapper.like(HkFormIndex.UPDATE_TIME,hkFormIndex.getUpdateTime());
                }*/
                if(StringUtils.isNotBlank(hkFormIndex.getAssessmentIndexIds())){
                entityWrapper.like(HkFormIndex.ASSESSMENT_INDEX_IDS,hkFormIndex.getAssessmentIndexIds());
                }
                if(StringUtils.isNotBlank(hkFormIndex.getFormIndexJson())){
                entityWrapper.like(HkFormIndex.FORM_INDEX_JSON,hkFormIndex.getFormIndexJson());
                }
                if(StringUtils.isNotBlank(hkFormIndex.getFormIndexName())){
                entityWrapper.like(HkFormIndex.FORM_INDEX_NAME,hkFormIndex.getFormIndexName());
                }
                if(StringUtils.isNotBlank(hkFormIndex.getAssessmentIndexId())){
                entityWrapper.like(HkFormIndex.ASSESSMENT_INDEX_ID,hkFormIndex.getAssessmentIndexId());
                }
        return entityWrapper;
        }
        }
